var TIMEREQUEST = 900;
var loaded = 0;
var numrow = 0;
var textsend = "";
var lengthtemp = 0;
var supportname = 'support';
var textcache = '';
var hasSendEmail=0;
function SendMessage()
{
    textsend += $("input_text").value + "||";
    $("input_text").value = ""
}
function AutoCheck()
{
    post = "rowed=" + numrow;
    post += "&ms=" + textsend;
    post += "&length=" + lengthtemp;
    if (($("input_text").value).length > 0) {
        post += "&typing=1";
    }
	if(hasSendEmail==1)
	{
		post +="&SendEmail=1&";
		alert("Sent all content chat to your email!");
	}
	hasSendEmail=0;
    textsend = "";
    ajaxLoader("guest.php?opt=check", post, "", "densang", "ProAutoCheck")
}
function ProAutoCheck(str)
{
    try
    {
        str = str.split("(*_*)");
        str2 = str[1];
        if (str != "")
        {
            arr = str2.split("$$");
            for (i = 0; i < arr.length; i++)
            {
                arr2b = arr[i].split("++");
                if (arr2b[1] == undefined) {
                    continue
                }
                cuser = "user2";
                ctext = "text2";
                if (username == arr2b[0]) {
                    cuser = "user1";
                    ctext = "text1"
                }
                textcache += "&nbsp;<span class=" + cuser + ">" + arr2b[0] + ":</span>";
                textcache += "<span class=" + ctext + ">" + arr2b[1] + "</span><br>";
                numrow++
            }
            $("displaydiv").innerHTML = textcache;
            if (str[2] == 1)
            {
                $("displaydiv").innerHTML += "<div class='typing'> <b>" + supportname + "</b> typing...</div>"
            }
            $("displaydiv").scrollTop += numrow * 20
        }
        if (str[0] == "banned") {
            return
        }
    }
    catch (e) {}
    setTimeout("AutoCheck()", TIMEREQUEST)
}
